package top.yxqz.spring.ioc.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import top.yxqz.spring.ioc.service.UserService;
import top.yxqz.spring.ioc.service.impl.UserServiceImpl;

/**
 * @author: 余小小
 * @date: 2023/4/6
 * @description： 响应处理地方
 * Controller：将类标识为控制层组件
 */
@Controller
public class UserController {

    @Autowired(required = true)
    @Qualifier("userService2")
    private UserService userService; //null 未注入的情况 使用spring来注入（1，set，2构造器）
//    private UserService userService = new UserServiceImpl(); //以前的注入方式

    //    /user/say/
    public void sayUserHello() {
        userService.sayUserHello();
    }

    public UserService getUserService() {
        return userService;
    }

    public void setUserService(UserService userService) {
        this.userService = userService;
    }
}
